Clarin9/Restrict main search page to items only - #1487
Conversation
484c30b to
d468754
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the shared search UI to allow callers to force specific DSpaceObjectType filters onto all search requests, and then uses that capability to restrict the main /search page to items only (matching legacy v7 behavior), without altering discovery configurations or other search surfaces.
Changes:
- Add a reusable
forcedDsoTypesinput toSearchComponentand thread it through the themed wrapper. - Apply
forcedDsoTypes = [ITEM]on the main search page template/component. - Add a unit test asserting that forced types are applied to computed search options.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/app/shared/search/themed-search.component.ts |
Proxies the new forcedDsoTypes input through the themed wrapper. |
src/app/shared/search/search.component.ts |
Introduces @Input() forcedDsoTypes and injects it into the combined PaginatedSearchOptions used for searches/CSV export. |
src/app/shared/search/search.component.spec.ts |
Adds a unit test to verify forced types are applied. |
src/app/search-page/search-page.component.ts |
Defines forcedDsoTypes = [ITEM] for the main search page. |
src/app/search-page/search-page.component.html |
Binds [forcedDsoTypes] into <ds-search> on /search. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The main /search page previously returned all DSpace object types (items, collections and communities), matching the backend `default` discovery configuration. In v7 only items were shown there. Add a reusable `forcedDsoTypes` input to the (themed) SearchComponent that forces the given DSpaceObject types onto every search request the component makes, and set it to items only on the main search page. Community and collection results are therefore hidden from /search, while other search pages (MyDSpace, admin, browse, scoped configuration searches) are untouched. Clearing SearchPageComponent.forcedDsoTypes restores the previous behaviour, and the input can be reused to expose this as a facet/config later. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
d468754 to
dfa1e5a
Compare
|
Superseded by backend PR dataquest-dev/DSpace#1423, which restricts the default Discovery search to items only at the source (single config value, applies to all API consumers — UI, REST, OAI — and to facet counts). Closing this UI-layer workaround as redundant. |
Problem
On the main /search page the result list shows all DSpace object types — items, collections and communities — because the backend
defaultdiscovery configuration indexes all of them. In v7 only items were shown on the search page.Verified against the live v9 dev backend (dev-6):
configuration=default→ 2373 resultsconfiguration=default&dsoType=item→ 2348 results (25 collections/communities filtered out)Fix (frontend only)
Add a reusable
forcedDsoTypesinput to the (themed)SearchComponent. When set, thoseDSpaceObjectTypes are forced onto every search request the component makes (they map todsoType=query params on the RESTdiscover/search/objectscall), regardless of the discovery configuration.The main search page sets it to items only, so community/collection results are hidden from
/search. Facets/filters are driven by the discovery configuration and are left untouched, as are all other search surfaces (MyDSpace, admin search, browse, scoped configuration searches).Why this shape
SearchPageComponent.forcedDsoTypesrestores the previous "all types" behaviour.dsoTypesarray; a caller that sets its own types is left untouched.Changes
shared/search/search.component.ts— new@Input() forcedDsoTypes; injected into the combined search options (so results and CSV export stay consistent).shared/search/themed-search.component.ts— thread the input through the themed wrapper.search-page/search-page.component.{ts,html}— setforcedDsoTypes = [ITEM]on the main search page (shared by base + custom theme).shared/search/search.component.spec.ts— test that the configured types are applied.Testing
tsc -p tsconfig.app.json --noEmitpasses.dsoTypefilter (counts above).🤖 Generated with Claude Code